{include file="common/_header"}

<body>

<div class="x-body layui-anim layui-anim-up">
    <form class="layui-form">
        <input type="hidden" name="product_id" value="{$data.product_id}">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">物流类型</label>
                <div class="layui-input-inline">
                    <select name="logistics_type">
                        <option value="1" >物流发货</option>
                        <option value="2" >直接入库</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">规格数量</label>
                {volist name="stock" id="v"}
                <div class="layui-input-block time-item">
                    <div  style="width:80px;display:inline-block;text-align: center;" >{$v['p_s_name']}：</div>
                    <input type="hidden" name="stock[{$key}][p_s_id]" class="layui-input" value="{$v['p_s_id']}">
                    <input type="text" name="stock[{$key}][number]" class="layui-input" style="width:120px;display:inline-block;" value="">
                </div>
                {/volist}
            </div>
        </div>
        <div style="margin-top: 50px; margin-right: 50px;text-align: center;">
            <button type="button" lay-submit lay-filter="add" class="layui-btn">立即提交</button>
        </div>
    </form>
</div>
</body>

<script>
    layui.use('form', function(){
        var form = layui.form;


        form.on('submit(add)', function (data) {
            $.ajax({
                'url': 'boxpurchase',
                'type': 'post',
                'data': data.field,
                'dataType': 'json',
                success: function (data) {
                    if(data.code == 1){
                        layer.msg(data.msg, {
                            icon: 6,
                            time: 800,
                        },function () {
                            window.parent.location.href = data.url;
                        })
                    } else {
                        layer.msg(data.msg, {
                            icon: 5,
                            time: 800,
                        },function(){
                            if(data.url != ""){
                                window.parent.location.href = data.url;
                            }
                        })
                    }
                }
            });
        })
    });

</script>


{include file="common/_bottom"}